package com.leo.version4;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;

/**
 * @ClassName FontAwesomeTRONDemo
 * @Description
 * @Author wangss
 * @date 2020.11.25 19:52
 * @Version 1.0
 */
public class FontAwesomeTRONDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("TRON Synopsis");
        // load the tron font.
        Font.loadFont(FontAwesomeTRONDemo.class.getResource("/font/TRON.TTF").toExternalForm(), 10);

        Label title = new Label("TRON");
        title.getStyleClass().add("title");

        Label caption = new Label("A sci-fi flick set in an alternate reality.");
        caption.getStyleClass().add("caption");
        caption.setMaxWidth(220);
        caption.setWrapText(true);
        caption.setTextAlignment(TextAlignment.CENTER);

        VBox layout = new VBox(10);
        layout.setStyle("-fx-padding: 20px; -fx-background-color: silver");
        layout.setAlignment(Pos.CENTER);
        layout.getChildren().setAll(title,
                new ImageView(new Image("http://ia.media-imdb.com/images/M/MV5BMTY5NjM2MjAwOV5BMl5BanBnXkFtZTYwMTgyMzA5.V1.SY317.jpg")),
                caption
        );

        // layout the scene.
        final Scene scene = new Scene(layout);
        scene.getStylesheets().add(getClass().getResource("/font/custom-font-styles.css").toExternalForm());
        stage.setScene(scene);
        stage.show();
    }
}
